<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;

/**
 * @package App\Http\Controllers\Api
 * @see PackageController
 */
class PackageController extends BaseController
{

    /**
     * add
     * @uri /package/add
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"name":"F11072E237189722","description":"A18AC22DC025C57D","is_public":"1E603E90CA728094"}
     * @response {"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6536\u85cf\u5939ID","name":"\u8fd9\u662f\u67d0\u7528\u6237\u65b0\u5efa\u7684\u6536\u85cf\u5939","description":"\u8fd9\u662f\u6536\u85cf\u5939\u63cf\u8ff0","total":"\u5185\u5bb9\u6570","is_default":0,"is_public":1,"is_deleted":0},"message":"OK"}
     */
    public function add(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6536\u85cf\u5939ID","name":"\u8fd9\u662f\u67d0\u7528\u6237\u65b0\u5efa\u7684\u6536\u85cf\u5939","description":"\u8fd9\u662f\u6536\u85cf\u5939\u63cf\u8ff0","total":"\u5185\u5bb9\u6570","is_default":0,"is_public":1,"is_deleted":0},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * del
     * @uri /package/del
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"id":"D92F543C7AF566B9"}
     * @response {"success":true,"statusCode":200,"result":true,"message":"OK"}
     */
    public function del(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":true,"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * edit
     * @uri /package/edit
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"id":"FC04903FA0539A1C","name":"B7309308140FDF5D","description":"7BBE84122A861115","is_public":"8BC230C7D1818512"}
     * @response {"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6536\u85cf\u5939ID","name":"\u8fd9\u662f\u67d0\u7528\u6237\u65b0\u5efa\u7684\u6536\u85cf\u5939","description":"\u8fd9\u662f\u6536\u85cf\u5939\u63cf\u8ff0","total":"\u5185\u5bb9\u6570","is_default":0,"is_public":1,"is_deleted":0},"message":"OK"}
     */
    public function edit(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6536\u85cf\u5939ID","name":"\u8fd9\u662f\u67d0\u7528\u6237\u65b0\u5efa\u7684\u6536\u85cf\u5939","description":"\u8fd9\u662f\u6536\u85cf\u5939\u63cf\u8ff0","total":"\u5185\u5bb9\u6570","is_default":0,"is_public":1,"is_deleted":0},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * getDetail
     * @uri /package/get-detail
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"id":"C6644367E9BBE3E2"}
     * @response {"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6536\u85cf\u5939ID","name":"\u8fd9\u662f\u67d0\u7528\u6237\u65b0\u5efa\u7684\u6536\u85cf\u5939","description":"\u8fd9\u662f\u6536\u85cf\u5939\u63cf\u8ff0","total":"\u5185\u5bb9\u6570","is_default":0,"is_public":1,"is_deleted":0},"message":"OK"}
     */
    public function getDetail(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6536\u85cf\u5939ID","name":"\u8fd9\u662f\u67d0\u7528\u6237\u65b0\u5efa\u7684\u6536\u85cf\u5939","description":"\u8fd9\u662f\u6536\u85cf\u5939\u63cf\u8ff0","total":"\u5185\u5bb9\u6570","is_default":0,"is_public":1,"is_deleted":0},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * getList
     * @uri /package/list
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"last_id":"171607ABA56047F6","user_id":"74F819898CA97333","target_id":"AA990B5295303E7F"}
     * @response {"success":true,"statusCode":200,"result":{"total_count":1,"page_size":20,"page":1,"list":[{"id":"00K6BQZ99T1IZB9ZXO0IUSZX","user_id":"00K6BQZ99T1IZB9ZXO0IUSZX","name":"\u9ed8\u8ba4\u6536\u85cf\u5939","description":"","total":7,"is_default":1,"is_deleted":0,"is_public":1,"updated_at":1605189506},{"id":"00KFNW99PUTOJA1JOAJSSUWE","user_id":"00K5H1KO60NAEIXXDT1SPMMM","name":"\u9ed8\u8ba4\u6536\u85cf\u5939","description":"","total":8,"is_default":1,"is_deleted":0,"is_public":1,"updated_at":1605273623,"is_collect":0}]},"message":"OK"}
     */
    public function getList(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"total_count":1,"page_size":20,"page":1,"list":[{"id":"00K6BQZ99T1IZB9ZXO0IUSZX","user_id":"00K6BQZ99T1IZB9ZXO0IUSZX","name":"\u9ed8\u8ba4\u6536\u85cf\u5939","description":"","total":7,"is_default":1,"is_deleted":0,"is_public":1,"updated_at":1605189506},{"id":"00KFNW99PUTOJA1JOAJSSUWE","user_id":"00K5H1KO60NAEIXXDT1SPMMM","name":"\u9ed8\u8ba4\u6536\u85cf\u5939","description":"","total":8,"is_default":1,"is_deleted":0,"is_public":1,"updated_at":1605273623,"is_collect":0}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * moreList
     * @uri /package/more-list
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"id":"77341CB0FC482B34"}
     * @response {"success":true,"statusCode":200,"result":{"total_count":1,"page_size":20,"page":1,"list":[{"id":"00K6BQZ99T1IZB9ZXO0IUSZX","user_id":"00K6BQZ99T1IZB9ZXO0IUSZX","name":"\u9ed8\u8ba4\u6536\u85cf\u5939","description":"","total":7,"is_default":1,"is_deleted":0,"is_public":1,"updated_at":1605189506}]},"message":"OK"}
     */
    public function moreList(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"total_count":1,"page_size":20,"page":1,"list":[{"id":"00K6BQZ99T1IZB9ZXO0IUSZX","user_id":"00K6BQZ99T1IZB9ZXO0IUSZX","name":"\u9ed8\u8ba4\u6536\u85cf\u5939","description":"","total":7,"is_default":1,"is_deleted":0,"is_public":1,"updated_at":1605189506}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * targetList
     * @uri /package/target-list
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"package_id":"47368D35E0FB7FAA","tab_type":"all","page_size":"3"}
     * @response {"success":true,"statusCode":200,"result":{"total_count":14,"page_size":3,"page":1,"list":[{"id":"00KC95OJSN7YUKOAMNANOOKG","cover_url":"b32caaecb7a14e9b5dd119d2569325c8.jpg","title":"如何用运营思维找到男朋友","description":"🔼点击上方蓝字关注我，和奥利一起进步互联网商业其实就是三个核心词：产品、流量、转化率。也就是产品的比拼、流量","is_deleted":0,"is_shield":0,"created_at":1594104659,"package_id":"00KEL6YTXKUZGAHBW7VGMDI7","collect_id":0,"target_type":1,"is_collect":false},{"id":"00KC5YNNAVUOAJILYSYCOM6J","cover_url":"568e90035aec7c9b9a96384c271d71e3.png","title":"Keep的背后，是无数人在薛定谔的健身","description":"不知道从什么时候开始，一股健身的浪潮席卷了我们……","is_deleted":0,"is_shield":0,"created_at":1594104541,"package_id":"00KEL6YTXKUZGAHBW7VGMDI7","collect_id":0,"target_type":1,"is_collect":false},{"id":"00KC5YI2WJHGTOMMPIMPVQ0M","cover_url":"e72ce83c9f86cc1159e09ceefd348429.jpg","title":"贾跃亭道歉背后：一封公开信再躲4年？承诺赔偿却没有一分钱真金白银","description":"贾跃亭虽然对股东作出了口头承诺，但对于乐视网来说，这28万散户却并不是其债权人。6月17日，乐视网发布澄清公","is_deleted":0,"is_shield":0,"created_at":1594104535,"package_id":"00KEL6YTXKUZGAHBW7VGMDI7","collect_id":0,"target_type":1,"is_collect":false}]},"message":"OK"}
     */
    public function targetList(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"total_count":14,"page_size":3,"page":1,"list":[{"id":"00KC95OJSN7YUKOAMNANOOKG","cover_url":"b32caaecb7a14e9b5dd119d2569325c8.jpg","title":"如何用运营思维找到男朋友","description":"🔼点击上方蓝字关注我，和奥利一起进步互联网商业其实就是三个核心词：产品、流量、转化率。也就是产品的比拼、流量","is_deleted":0,"is_shield":0,"created_at":1594104659,"package_id":"00KEL6YTXKUZGAHBW7VGMDI7","collect_id":0,"target_type":1,"is_collect":false},{"id":"00KC5YNNAVUOAJILYSYCOM6J","cover_url":"568e90035aec7c9b9a96384c271d71e3.png","title":"Keep的背后，是无数人在薛定谔的健身","description":"不知道从什么时候开始，一股健身的浪潮席卷了我们……","is_deleted":0,"is_shield":0,"created_at":1594104541,"package_id":"00KEL6YTXKUZGAHBW7VGMDI7","collect_id":0,"target_type":1,"is_collect":false},{"id":"00KC5YI2WJHGTOMMPIMPVQ0M","cover_url":"e72ce83c9f86cc1159e09ceefd348429.jpg","title":"贾跃亭道歉背后：一封公开信再躲4年？承诺赔偿却没有一分钱真金白银","description":"贾跃亭虽然对股东作出了口头承诺，但对于乐视网来说，这28万散户却并不是其债权人。6月17日，乐视网发布澄清公","is_deleted":0,"is_shield":0,"created_at":1594104535,"package_id":"00KEL6YTXKUZGAHBW7VGMDI7","collect_id":0,"target_type":1,"is_collect":false}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

}